package com.movisol.messenger.views.controls;

import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;

import com.movisol.tools.HelperUtils;

public class Globito extends Drawable {
	private final int width;
	private final int height;
	private final boolean right;
	private final int color;
	private final float scale;
	
	public Globito(int width, int height, boolean right, int color, float scale)
	{
		this.width = width;
		this.height = height;
		this.right = right;
		this.color = color;
		this.scale = scale;
	}

	@Override
	public void draw(Canvas canvas) {
		
		Paint paint = new Paint();
		paint.setStyle(Paint.Style.FILL);

		// draw a solid green rectangle
		paint.setAntiAlias(true);
		paint.setTextSize(30);
		RectF r = new RectF();
		Path path = new Path();
		paint.setColor(color);

		if(!right)
		{
			//Set the rectangle bounds
			r.set(HelperUtils.dpToPixels(16, scale), 0,
					HelperUtils.dpToPixels(17, scale) + width + HelperUtils.dpToPixels(6, scale), height + 10);
			
			//Round the corners of the rectangle
			canvas.drawRoundRect(r, 10, 10, paint);
			
			//Draw the triangle
			path.moveTo(30, 0);
			path.lineTo(30, HelperUtils.dpToPixels(12, scale));
			path.lineTo(5, HelperUtils.dpToPixels(16, scale));
			path.close();
			path.offset(0, (height - HelperUtils.dpToPixels(12, scale)) / 2);
		
		}
		else
		{
			r.set(0, 0, HelperUtils.dpToPixels(1, scale) + width + HelperUtils.dpToPixels(6, scale), height + 10);

			canvas.drawRoundRect(r, 10, 10, paint);
			
			path.moveTo(2 + width + 5, 0);
			path.lineTo(2 + width + 5, HelperUtils.dpToPixels(12, scale));
			path.lineTo(32 + width, HelperUtils.dpToPixels(16, scale));
			path.close();
			path.offset(-HelperUtils.dpToPixels(2, scale), (height - HelperUtils.dpToPixels(12, scale)) / 2);
		}
		
		canvas.drawPath(path, paint);
	}

	@Override
	public int getOpacity() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void setAlpha(int alpha) {
		// TODO Auto-generated method stub

	}

	@Override
	public void setColorFilter(ColorFilter cf) {
		// TODO Auto-generated method stub

	}

}
